//! Copyright 2012 Virtium Technology, Inc.
//! All rights reserved
//!
#ifndef __Reader_h__
#define __Reader_h__

#include "BasicTypes.h"
#include "SysTick.h"

#if defined (__FW_BUILD__)
extern "C" {
    extern volatile U8  s_ClkFlag;
    extern volatile U8  s_BitCount;
    extern volatile U8  s_Magstripe[];
    extern volatile U32 s_CardData;

    extern void EXTI2_IRQHandler(void);
    extern void EXTI3_IRQHandler(void);
}
#endif

#define WEIGAND_BITS_LENGTH     34

class cReader
{
public:
    static void InitReset();
    static U32  GetNewCard();
    static void RunOne();

private:
    static void CleanUpCardDataBuffer();
    static U32  DecodeWeigand();

private:
#if !defined (__FW_BUILD__)
    static U8   s_ClkFlag;
    static U8   s_BitCount;
    static U8   s_Magstripe[];
    static U32  s_CardData;
#endif

    static bool s_NewCardFlag;
    static cSysTick s_CardTimeout;
};

#endif // __Reader_h__
